<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no">
	<title>输入密码</title>
	<link rel="stylesheet" type="text/css" href="/static/bootstrap/css/bootstrap.min.css"/>
    <style>
        .password-box {
            width:300px;margin:60px auto;
        }
        fieldset {
            border:1px solid #ccc;padding:20px;border-radius:3px;
        }
        legend {
            border:0;width:auto;font-size:16px;
        }
    </style>
</head>
<body>
<div class="password-box">
    <fieldset>
        <legend>输入密码查看分享</legend>
        <form action="javascript:" id="fm-confirm-pwd">
            <div class="form-group">
                <input type="text" name="password" oninvalid="setCustomValidity('请输入密码')" oninput="setCustomValidity('')" required maxlength="4" autocomplete="off" placeholder="密码" class="form-control">
            </div>
            <div class="form-group">
                <input type="hidden" name="share_id" value="{{ share_id }}">
                <input type="submit" value="确 定" class="btn btn-primary btn-block">
            </div>
        </form>
    </fieldset>
</div>

<script type="text/javascript" src="/static/js/jquery.js"></script>
<script>$.ajaxSetup({headers:{"X-CSRFToken":"{{ csrf_token }}"}})</script>
<script type="text/javascript" src="/static/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/static/layer/layer.js" ></script>
<script>
$("#fm-confirm-pwd").on("submit", function() {
    var layIndex = layer.load(0);
    var password = $("[name=password]").val();
    var shareId = $("[name=share_id]").val();
    $.post("/validsp/", {"password": password, "share_id": shareId}, function(result) {
        layer.close(layIndex);
        if (result.code == 1000) {
            location.href = "/eshare_list/{0}/{1}".replace("{0}", shareId).replace("{1}", password);
        } else {
            layer.msg(result.msg);
        }
    });
});
</script>
</body>
</html>